﻿using StrokeCenterSystem.Areas.StrokeCenter.Models;
using StrokeCenterSystem.Code.Bll;
using StrokeCenterSystem.Core;
using StrokeCenterSystem.ThreeCenterManage;
using StrokeCenterSystem.Utils;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace StrokeCenterSystem.Areas.StrokeCenter.Controllers
{
    public class QualityPointController : BaseController
    {
        //
        // GET: /StrokeCenter/QualityPoint/

        public ActionResult Index()
        {
            return View();
        }


        /// <summary>
        /// 诊疗路径列表
        /// </summary>
        /// <returns></returns>
        public ActionResult Search()
        {
            OperateResult resultInfo = PathwayManager.GetQualityPointList();
            var res = new { Rows = resultInfo.Body };
            return Content("{\"Rows\":" + resultInfo.Body + "}");
        }

        public ActionResult GetTableColumnList()
        {
            OperateResult resultInfo = PathwayManager.GetTableColumnList();
            return Content(resultInfo.Body.ToString());
        }

        /// <summary>
        /// 添加/编辑路径
        /// </summary>
        /// <returns></returns>
        public ActionResult Edit(string Id)
        {
            ViewBag.Id = Id;
            return View();
        }

        /// <summary>
        /// 保存新增或者编辑信息
        /// </summary>
        /// <returns></returns>
        public ActionResult EditSubmit()
        {
            QualityPointSet qp = new QualityPointSet()
            {
                Id = WebUtils.GetInt("Id"),
                Title = WebUtils.GetString("Title"),
                QualityPointTCId = WebUtils.GetInt("QualityPointTCId"),
                QualityPointTitle = WebUtils.GetString("QualityPointTitle"),
                QualityPointName = WebUtils.GetString("QualityPointName"),
                QualityPointTableName = WebUtils.GetString("QualityPointTableName"),
                ComparePointTCId = WebUtils.GetInt("ComparePointTCId"),
                ComparePointTitle = WebUtils.GetString("ComparePointTitle"),
                ComparePointName = WebUtils.GetString("ComparePointName"),
                ComparePointTableName = WebUtils.GetString("ComparePointTableName"),
                OverTime = WebUtils.GetInt("OverTime"),
                Sort = WebUtils.GetInt("Sort"),
                Status = WebUtils.GetInt("Status")
            };
            OperateResult result = PathwayManager.SaveQualityPoint(qp);
            return Content(result.Body.ToString());
        }

        public ActionResult GetDataById(int id = 0)
        {
            if (id > 0)
            {
                OperateResult resultInfo = PathwayManager.GetQualityPointList(id);
                return Content(resultInfo.Body.ToString());
            }
            return Content("[]");
        }

        public ActionResult ChangeStatus()
        {
            int id = WebUtils.GetInt("Id");
            int Status = WebUtils.GetInt("Status");
            OperateResult result = PathwayManager.ChangeStatus(id, Status);
            return Content(result.Body.ToString());
        }
    }
}
